<template>
	<view class="scan">
		<view class="mask">
			<text>确认要扫码吗&nbsp;？</text>
			<view class="btn-wrap">
				<button class="cancel" @click="cancel">取消</button>
				<button class="save" @click="save">确定</button>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		onMounted,
		ref,
		onUnmounted
	} from 'vue';

	import {
		onShow,
		onLoad,
		onHide,
		onUnload,
		onReady

	} from "@dcloudio/uni-app"

	let flag = ref(true)
	let cancel = () => {
		uni.switchTab({
			url: "/pages/home/home"
		})

	}
	let save = () => {
		if (!uni.getStorageSync('TOKEN')) {
			uni.showToast({
				title: '暂无权限,请先登录！',
				icon: 'none'
			})
			return
		}

		uni.scanCode({

			success: function(res) {

				let code = res.result
				if (res.result) {
					uni.showLoading({
						title: "跳转中..."
					})
					uni.navigateTo({
						url: `/homePageOther/trashChange/trashChange?code=${code}`
					})
					uni.hideLoading()

				}
				uni.hideLoading()
			},
			fail(e) {
				uni.switchTab({
					url: "/pages/home/home"
				})

				uni.hideLoading()
			}

		})






	}

	onShow(() => {





	})
</script>

<style lang="scss" scoped>
	.scan {
		width: 100vh;
		height: 100vh;
		position: relative;
		background-color: rgba(0, 0, 0, .6);

		.mask {
			position: fixed;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			width: 550rpx;

			background-color: #fff;

			border-radius: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-bottom: 30rpx;

			text {
				font-size: 32rpx;
				font-weight: 400;
				color: #000;
				height: 200rpx;
				line-height: 200rpx;
			}

			.btn-wrap {
				display: flex;
				justify-content: space-around;
				align-items: center;
				font-size: 32rpx;
				font-weight: 400;
				color: #000;
				// border-top: 2rpx solid #ccc;
				// border-radius: none;
				width: 100%;

				.cancel {
					height: 90rpx;
					line-height: 90rpx;

					text-align: center;
					width: 250rpx;
					border: 2rpx solid #ECECEC;
					border-radius: 60rpx;

				}

				.save {
					width: 250rpx;
					height: 90rpx;
					line-height: 90rpx;
					color: #fff;
					text-align: center;
					background-color: rgba(0, 0, 255, .6);
					border-radius: 60rpx;

				}
			}
		}
	}
</style>